import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    songList: [],
    songData:[],
    play_url: '',
    // mp3:''
  },
  mutations: {
  },
  actions: {
    async getSongList({ state }, songName) {
      let { data } = await axios({
        method: 'get',
        url: "/songData",
        params: {
          songName
        }
      })
      state.songList = data
    },
    async getDownLink({ state }, { id, hash }) {
      let { data } = await axios({
        method: 'get',
        url: '/down',
        params: {
          id,
          hash
        }
      })
      state.songData = data
      state.play_url = data.play_url
    }
  },
  modules: {
  }
})
